fix(web): guard undefined hash in commit detail view - #7148
Conversation
9fc67c1 to
818473d
Compare
rahulshendre
left a comment
There was a problem hiding this comment.
LGMT, thanks @vikash7485
one thing I am curious about - commit.hash is typed string from the protobuf (proto3 defaults an unset string to "", not undefined), so I couldn't see where it'd actually be undefined.
If you saw it, please let use know where, mostly so we know if message/url next to it need the same
|
@rahulshendre Thanks for the review and approval The reason In standard protobuf generated classes, proto3 does default strings to |
✅ Deploy Preview for pipecd-site canceled.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7148 +/- ##
==========================================
- Coverage 29.68% 29.01% -0.68%
==========================================
Files 601 532 -69
Lines 64383 58157 -6226
==========================================
- Hits 19113 16873 -2240
+ Misses 43779 39919 -3860
+ Partials 1491 1365 -126
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@vikash7485 same here, need to run make lint/web on your local to fix this |
Head branch was pushed to by a user without write access
1390e3b
|
@vikash7485 the DCO check has failed 👀 You need to sign-off the commit 😁 |
…on test Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
e4d49c4 to
e7b4c61
Compare
|
Thank you for contributing to PipeCD, @vikash7485! The changes in this pull request will be part of the upcoming release! |
What this PR does:
Guard against
undefinedhash in the deployment detail commit section by adding a null-coalescing fallback (?? "") before calling.slice(0, 7).Why we need it:
When
deployment.trigger.commit.hashisundefined(possible from older Piped v0 protobuf messages where the field was unpopulated), the current code calls.slice(0, 7)directly onundefined, causing a runtime crash:The outer guard at L254 (
deployment.trigger?.commit &&) only checks thatcommitexists, not thathashis populated. This fix adds a safe fallback so the link renders with an empty string instead of crashing.Which issue(s) this PR fixes:
Fixes #
Does this PR introduce a user-facing change?:
No. This prevents a crash for an edge case. Users with valid commit hashes see no difference.